﻿using ASmile.Com;
using ASmile.Com.Da;
using ASmile.Com.MenuRole;
using ASmile.DBModel;
using Microsoft.AspNetCore.Mvc;

namespace ASmile.Web.ApiControllers.SysManage
{
    /// <summary>
    /// 菜单角色
    /// </summary>
    [Route("api/SysManage/[controller]/[action]")]
    [ApiExplorerSettings(GroupName = "SysManage")]
    public class MenuRoleController : BaseApiController<MenuRoleBLL>
    {
        ///// <summary>
        ///// 新增保存
        ///// </summary>
        //[HttpPost]
        //public virtual ApiResult<string> RoleAdd(Sys_Role model)
        //{
        //    return BLLObj.RoleAdd(model);
        //}
        ///// <summary>
        ///// 编辑保存
        ///// </summary>
        //[HttpPost]
        //public virtual ApiResult<string> RoleEdit(Sys_Role model)
        //{
        //    return BLLObj.RoleEdit(model);
        //}
        ///// <summary>
        ///// 删除
        ///// </summary>
        //[HttpPost]
        //public ApiResult RoleDel(Sys_Role model)
        //{
        //    return BLLObj.RoleDel(model);
        //}
        ///// <summary>
        ///// 获取数据
        ///// </summary>
        //[HttpPost]
        //public ApiResultList<Sys_Role> RoleGetData()
        //{
        //    return BLLObj.RoleGetData();
        //}

        #region 菜单树

        /// <summary>
        /// 菜单分类列表（非菜单的树形结构）
        /// </summary>
        [HttpPost]
        public ApiResultList<Sys_RoleMenu> TreeGetData(ArgId arg)
        {
            return BLLObj.TreeGetData(arg.Id);
        }

        [HttpPost]
        public ApiResult<string> TreeAdd(Sys_RoleMenu m)
        {
            return BLLObj.TreeAdd(m);
        }

        [HttpPost]
        public ApiResult<string> TreeEdit(Sys_RoleMenu m)
        {
            return BLLObj.TreeEdit(m);
        }

        [HttpPost]
        public ApiResult TreeChangeParentId(Sys_RoleMenu m)
        {
            return BLLObj.TreeChangeParentId(m);
        }
        [HttpPost]
        public ApiResult TreeDel(Sys_RoleMenu menu)
        {
            return BLLObj.TreeDel(menu);
        }
        /// <summary>
        /// 交换排序
        /// </summary>
        [HttpPost]
        public ApiResult SwapOrderNo(ArgSwapOrderNo arg)
        {
            return BLLObj.SwapOrderNo(arg);
        }

        #endregion

        #region 角色菜单
        [HttpPost]
        public ApiResultList<Sys_Menu> GetMenuTree()
        {
            return BLLObj.GetMenuTree();
        }
        [HttpPost]
        public ApiResult<string> AddRoleMenu(Sys_RoleMenu model)
        {
            return BLLObj.AddRoleMenu(model);
        }
        [HttpPost]
        public ApiResult<string> EditRoleMenu(Sys_RoleMenu model)
        {
            return BLLObj.EditRoleMenu(model);
        }

        [HttpPost]
        public ApiResult DelRoleMenu(Sys_RoleMenu model)
        {
            return BLLObj.DelRoleMenu(model);
        }

        /// <summary>
        /// 根据父级Id获取所有子菜单
        /// </summary>
        [HttpPost]
        public ApiResultList<Sys_RoleMenu> GetRoleMenus(ArgGetRoleMenus arg)
        {
            return BLLObj.GetRoleMenus(arg);
        }

        #endregion
        /// <summary>
        /// 修改菜单的排序号
        /// </summary>
        [HttpPost]
        public ApiResult SetRoleMenuOrder(dynamic arg)
        {
            string id = arg.id;
            int orderNo = arg.orderNo;
            return BLLObj.SetRoleMenuOrder(id, orderNo);
        }
        /// <summary>
        /// 修改菜单工具栏的排序号
        /// </summary>
        [HttpPost]
        public ApiResult SetRoleToolMenuOrder(dynamic arg)
        {
            string id = arg.id;
            int orderNo = arg.orderNo;
            return BLLObj.SetRoleToolMenuOrder(id, orderNo);
        }
        /// <summary>
        /// 更新排序
        /// </summary>
        [HttpPost]
        public ApiResult SetOrderNo(dynamic arg)
        {
            string id = arg.id;
            int orderNo = arg.orderNo;
            return BLLObj.SetOrderNo(id, orderNo);
        }
        /// <summary>
        /// 重置父级节点
        /// </summary>
        [HttpPost]
        public ApiResult SetParent(dynamic arg)
        {
            string srcId = arg.srcId;
            string tarPId = arg.tarPId;
            int orderNo = arg.orderNo;
            return BLLObj.SetParent(srcId, tarPId, orderNo);
        }
    }
}